<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

    <script>
        // forEach() 遍历
        {
            console.log('*******forEach*******');
            let chekList = [true, false, true, false]
            chekList.forEach((item) => {
                item = false;
            })
            console.log(chekList);
        }
        {
            console.log('*******forEach*******');
            let arr = [{ a: 10 }, { a: 88 }]
            arr.forEach((item) => {
                item.a = 999;
            })
            console.log(arr);
        }

        {
            console.log('*******map*******');
            let chekList = [true, false, true, false]
            chekList.map((item) => {
                item = false;
            })
            console.log(chekList);
        }
        // map() 遍历
        {
            console.log('*******map*******');
            let arr = [{ a: 10 }, { a: 88 }]
            arr.map((item) => {
                item.a = 888;
            })
            console.log(arr);
        }
        // filter()  筛选  使用数组中通过测试的每个元素创建新数组,返回包含所有通过测试的数组元素的数组 ,没有返回空数组
        {
            console.log('*******filter*******');
            let arr = [32, 41, 55, 17, 19]
            let res = arr.filter((item) => {
                return item >= 18
            })
            console.log(res);
        }
        // every()  检查数组中的每个元素是否通过测试,返回布尔值,如果所有元素都复合返回true,否则返回false
        {
            console.log('*******every*******');
            let arr = [100, 20, 30, 55]
            let res = arr.every((curr, index) => {
                return curr > 1;
            })
            console.log(res);
        }
    </script>
</body>

</html>